<?php

namespace common\validate;


class Note extends BaseValidate
{
    // 验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.note.link_id', 'integer')
            ->append('data.note.module_id', 'integer')
//            ->append('data.note.text', 'require')
            ->append('data.note.demand_type', 'in:feedback,review_feedback,repair_feedback,demand,comment,task_progress')
            ->append('data.note.type', 'in:text,video,audio')
            ->append('data.note.stick', 'in:yes,no')
            ->append('data.note.version_check_list_id', 'integer');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.type', 'in:text,audio')
            ->append('data.stick', 'in:yes,no');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // SelectWithUserDetail 验证场景定义
    public function sceneSelectWithUserDetail()
    {
        return $this->append('param', 'require|array');
    }


    public function sceneGetVersionNote()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array')
            ->append('param.filter.version_id', 'require|integer');
    }

    // 添加需求关联验证
    public function sceneAddNoteEntityRelationBase()
    {
        return $this->append('relation_type', 'require|in:episode,entity,step_category,step,todo,scene')
            ->append('project_id', 'integer')
            ->append('entity_id', 'integer')
            ->append('step_category_id', 'requireIf:relation_type,step_category');
    }

    // 添加需求关联验证
    public function sceneAddNoteEntityRelation()
    {
        return $this->append('relation_type', 'require|in:episode,entity,step_category,step,scene')
            ->append('project_id', 'require|integer')
            ->append('episode_code', 'require')
            ->append('entity_id', 'require|integer')
            ->append('step_category_id', 'requireIf:relation_type,step_category')
            ->append('task_id', 'integer|requireIf:relation_type,step');
    }

    // 添加需求关联验证
    public function sceneAddNoteEntityRelationTodo()
    {
        return $this
            ->append('project_id', 'integer')
            ->append('task_id', 'require|integer')
            ->append('project_id', 'integer')
            ->append('entity_id', 'integer')
            ->append('step_category_id', 'integer');
    }

    public function sceneGetDemandNoteList()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array');
    }

    public function sceneGetLastDemandNoteListTextByTaskIds()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter.task_id', 'require|array|length:2');
    }

    public function sceneDemandInformation()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array');
    }

    public function sceneGetDemandEntityList()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array');
    }

    public function sceneGetChatDemandList()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array');
    }

    public function sceneGetTaskDemandNoteList()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array')
            ->append('param.filter.task_id', 'require');
    }

    public function sceneGetEntityDemandNoteList()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array')
            ->append('param.filter.entity_id', 'require');
    }

    public function sceneDelDemandRelationEntity()
    {
        return $this->append('param', 'require|array')
            ->append('param.filter', 'require|array')
            ->append('param.filter.id', 'require');
    }

    public function sceneGetList()
    {
        return $this->append('param', 'require|array')
            ->append('module_code', 'require');
    }

    public function sceneGetEpisodeShot()
    {
        return $this->append('param', 'require|array')
            ->append('param.entity_id', 'require|integer');
    }

    public function sceneDeleteDemandNote()
    {
        return $this->append('param.filter', 'require|array');
    }

    public function sceneGetAssetNote()
    {
        return $this->append('param.filter.entity_ids', 'require');
    }

    public function sceneImportDemand()
    {
        return $this->append('module_code', 'require')
            ->append('project_id', 'require')
            ->append('data', 'require|array');
    }

    public function sceneImportDemandDataItem()
    {
        return $this->append('initial_episode_code', 'require')
            ->append('showings_number', 'require')
            ->append('name', 'require');
    }
}
